<?php
class ui_glob_nav extends ui {
	public function __construct($S, $param) {
		parent::__construct();
		
		if ($this->uid) {
			// 用户基本信息 -------------------------------------------------------------------------------------------------
			$data_user = new data_user();
			$me = $data_user->one($this->uid);
			if ($me) {
				$S->assign('nickname', $me['nickname']);
				$S->assign('meid', $me['id']);

				// 构造关于登陆账号
				$data_social = new data_social();
				if ($me['weibo_id']) {
					if ($me['weibo_token']) {
						$is_login[] = '<img class="social_icon" src="/images/icon_weibo_16.png" title="新浪微博已经登录成功">';
					} else {
						$not_login[] = array (
							'link'		=> '<a href="'.$data_social->get_authorize_url('weibo').'"><img src="/images/login_weibo.png" title="点击进入新浪微博授权页面" alt="点击进入新浪微博授权页面" border="0" />',
							'img'		=> '<img class="social_icon" src="/images/icon_weibo_16_grey.png" title="新浪微博授权过期，请重新登陆">',
						);
					}
				}
				if ($me['renren_id']) {
					if ($me['renren_token']) {
						$is_login[] = '<img class="social_icon" src="/images/icon_renren_16.png" title="人人网已经登录成功">';
					} else {
						$not_login[] = array (
							'link'		=> '<a href="'.$data_social->get_authorize_url('renren').'"><img src="/images/login_renren.png" title="点击进入人人网授权页面" alt="点击进入人人网授权页面" border="0" />',
							'img'		=> '<img class="social_icon" src="/images/icon_renren_16_grey.png" title="人人网授权过期，请重新登陆">',
						);
					}
				}
				if ($me['kaixin001_id']) {
					if ($me['kaixin001_token']) {
						$is_login[] = '<img class="social_icon" src="/images/icon_kaixin001_16.png" title="开心网已经登录成功">';
					} else {
						$not_login[] = array (
							'link'		=> '<a href="'.$data_social->get_authorize_url('kaixin001').'"><img src="/images/login_kaixin001.png" title="点击进入开心网授权页面" alt="点击进入开心网授权页面" border="0" />',
							'img'		=> '<img class="social_icon" src="/images/icon_kaixin001_16_grey.png" title="开心网授权过期，请重新登陆">',
						);
					}
				}
				if ($me['qqwb_id']) {
					if ($me['qqwb_token']) {
						$is_login[] = '<img class="social_icon" src="/images/icon_qqwb_16.png" title="腾讯微博已经登录成功">';
					} else {
						$not_login[] = array (
							'link'		=> '<a href="'.$data_social->get_authorize_url('qqwb').'"><img src="/images/login_qqwb.png" title="点击进入腾讯微博授权页面" alt="点击进入腾讯微博授权页面" border="0" />',
							'img'		=> '<img class="social_icon" src="/images/icon_qqwb_16_grey.png" title="腾讯微博授权过期，请重新登陆">',
						);
					}
				}

				$S->assign('is_login', $is_login);
				$S->assign('not_login', $not_login);


				// 构造导航
				$nav = array (
					array('name'=>'阅读圈', 	'href'=>'/index.php', 			'class_name'=>'nd'),
					array('name'=>'我的存档', 	'href'=>'/saved.php', 			'class_name'=>'nd'),
					array('name'=>'好友推荐', 	'href'=>'/recommend.php', 		'class_name'=>'nd'),
					array('name'=>'朋友', 		'href'=>'/friend.php', 			'class_name'=>'nd'),
					array('name'=>'热门', 		'href'=>'/hot.php', 			'class_name'=>'nd'),
				);
				switch ($_SERVER['PHP_SELF']) {
					case '/index.php':
						$nav[0]['class_name'] = 'na';
						break;
					case '/saved.php':
						$nav[1]['class_name'] = 'na';
						break;
					case '/recommend.php':
						$nav[2]['class_name'] = 'na';
						break;
					case '/friend.php':
						$nav[3]['class_name'] = 'na';
						break;
					case '/hot.php':
						$nav[4]['class_name'] = 'na';
						break;
				}
				$S->assign('nav', $nav);
			} else {
				echo '
					<script type="text/javascript">
						location.href = "/?logout=1";
					</script>
				';
				die();
			}
		}
	}
}
?>